package graphdisplay;

import java.util.List;

public class WeightedEdge extends AbstractGraph.Edge
        implements Comparable<WeightedEdge> {

    public int weight; // The weight on edge (u, v)
    public int u, v;
    List<Node> vertices;

    /** Create a weighted edge on (u, v) */
    public WeightedEdge(int u, int v, int weight) {
        super(u, v);
        this.u = u;
        this.v = v;
        this.weight = weight;
    }
    
    public WeightedEdge(Node node1, Node node2, int weight, List<Node> vertices) {
        super(vertices.indexOf(node1), vertices.indexOf(node2));
        System.out.println("node1 index = " + vertices.indexOf(node1) + " node2 index = " + vertices.indexOf(node2));
        this.u = u;
        this.v = v;
        this.weight = weight;
    }

    /** Compare two edges on weights */
    public int compareTo(WeightedEdge edge) {
        if (weight > edge.weight) {
            return 1;
        } else if (weight == edge.weight) {
            return 0;
        } else {
            return -1;
        }
    }
}
